//
//  ViewController.swift
//  SimplePhotoBrowser
//
//  Created by nimo on 2017/5/4.
//  Copyright © 2017年 nimoAndHisFriends. All rights reserved.
//

import UIKit

class Photo: UIViewController,UIScrollViewDelegate {
    
    var imageView:UIImageView!
    var scrollView:UIScrollView!
    override func viewDidLoad() {
        super.viewDidLoad()
//        image 充满整个容器
        imageView = UIImageView(frame: self.view.bounds)
        imageView.image = UIImage(named: "samplePhoto.jpeg") //声明图片
        imageView.isUserInteractionEnabled = true            //响应交互
        scrollView = UIScrollView(frame: self.view.frame)    //声明滚动视图
        scrollView.maximumZoomScale = 4.0                    //缩放
        scrollView.minimumZoomScale = 1
        scrollView.backgroundColor = UIColor.black          //背景色
        scrollView.contentSize = imageView.bounds.size      //可以滚动的区域
        scrollView.delegate = self
        self.view.addSubview(scrollView)
        scrollView.addSubview(imageView)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imageView
    }
}

